package com.qiuzhiyi;

import android.app.Activity;
import android.app.Application;
import android.content.Context;

import com.mob.MobSDK;

import java.util.ArrayList;
import java.util.List;

/**
 * Author: Li
 * Date: 2017/9/11 0011
 * Description: App
 */


public class App extends Application {

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        MobSDK.init(this);
    }

    public static List<Activity> activityList;
    public static void addActivity(Activity activity){
        if (activityList == null) {
            activityList=new ArrayList<>();
        }
        if (activityList.contains(activity)) {
            return;
        }
        activityList.add(activity);
    }
    public static void removeActivity(Activity activity){
        if (activityList == null) {
            return;
        }
        if (activityList.contains(activity)) {
            activityList.remove(activity);
        }
    }
    public static void finishAll(){
        if (activityList==null) {
            return;
        }
        for (Activity activity : activityList) {
            activity.finish();
        }
    }

    public static void clearActivity(){
        activityList.clear();
    }
}
